#if !defined(APP_SERIAL_H)
#define APP_SERIAL_H
#include <termios.h>
#include "app_device.h"
#include "app_message.h"
//波特率枚举
typedef enum
{
    BR_9600 = B9600,
    BR_115200 = B115200
}BranudRate;
//校验位枚举
typedef enum
{
    Parity_None = 0,
    Parity_Odd = PARENB|PARODD,
    Parity_Even = PARENB

}Parity;

//停止位枚举
typedef enum
{   
    Stopbits_1  = 0,
    Stopbits_2 = CSTOPB

}Stopbits;

//串口设备结构体
typedef struct
{
    Device super;
    BranudRate braud_rate;
    Parity parity;
    Stopbits stop_bits;
}SerialDevice;


//初始化
SerialDevice *app_serial_init(char *filename);

//设置波特率
int app_serial_serBraudRate(SerialDevice *serial,BranudRate braud_rate);

//设置校验位
int app_serial_setParity(SerialDevice *serial,Parity parity);

//设置停止位
int app_serial_setStopBits(SerialDevice *serial,Stopbits stop_bits);

//设置连接类型
int app_serial_setConnectType(SerialDevice *serial,ConnectionType conn_type);

#endif // APP_SERIAL_H
